package com.yc.pre.utils;

import java.util.List;

/**
 * @author baozhuangyu
 * @Date 2020/12/7  10:39
 */
public class SliderCaptchaUtil {
    //滑块行为校验
    public static boolean isVerify(List<Integer> datas,Boolean boo){
        //判断拖动是否正确
        if (!boo||datas.isEmpty()){
            return false;
        }
        //判断是否人机，y轴移动距离不等于0为true
        int sum = 0;
        for (Integer data : datas) {
            sum += data;
        }
        double avg = sum * 1.0 / datas.size();

        double sum2 = 0.0;
        for (Integer data : datas) {
            sum2 += Math.pow(data - avg, 2);
        }

        double stddev = sum2 / datas.size();
        return stddev != 0;
    }

}
